package com.fangrui.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

//Created by ✎﹏ℳ๓独赏☆独醉 on 2025/5/3 17:04
@Slf4j
@Component
//@Aspect
public class MyAspectDemo01 {
    @Pointcut("execution(* com.fangrui.service.impl.DeptServiceImpl.*(..))")//切入点表达式的抽取
    public void pc(){};

    @Before("pc()")
//    @Before("execution(* com.fangrui.service.impl.DeptServiceImpl.*(..))")//切入点表达式
    public void before() {
        log.info("before ...");
    }
    @After("pc()")
//    @After("execution(* com.fangrui.service.impl.DeptServiceImpl.*(..))")
    public void after() {
        log.info("after ...");
    }
    @Around("pc()")
//    @Around("execution(* com.fangrui.service.impl.DeptServiceImpl.*(..))")
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
        log.info("around before ...");
        Object proceed = joinPoint.proceed();
        log.info("around after ...");
        return proceed;
    }
    @AfterReturning("pc()")
//    @AfterReturning("execution(* com.fangrui.service.impl.DeptServiceImpl.*(..))")
    public void afterReturning() {
        log.info("afterReturning ...");
    }
    @AfterThrowing("pc()")
//    @AfterThrowing("execution(* com.fangrui.service.impl.DeptServiceImpl.*(..))")
    public void afterThrowing() {
        log.info("afterThrowing ...");
    }
}
